package com.fansl.allround.common.core.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.concurrent.TimeUnit;

/**
 * @author fansl
 * @Description: 登录发送手机验证码时间间隔
 * @date 2019/11/5 11:01
 */
@Getter
@AllArgsConstructor
public enum LoginSmsTimeIntervalEnum {
    ONE(1,1,TimeUnit.MINUTES),
    TOW(2,3,TimeUnit.MINUTES),
    THIRD(3,5,TimeUnit.MINUTES),
    FOUR(4,10,TimeUnit.MINUTES),
    FIVE(5,30,TimeUnit.MINUTES),
    /**
     * 最大次数
     */
    MAX(5,0,TimeUnit.MINUTES),
    ;
    /**
     * 次数
     */
    private final int times;
    /**
     * 间隔时长(单位)
     */
    private final int interval;
    /**
     * 时长单位
     */
    private final TimeUnit timeUnit;

    public static LoginSmsTimeIntervalEnum getByTimes(int times){
        for (LoginSmsTimeIntervalEnum value:LoginSmsTimeIntervalEnum.values()){
            if (value.times==times){
                return value;
            }
        }
        return ONE;
    }
}
